import Book.Library;
import User.ProxyUser;
import User.Factory.AdminFactory;
import User.Factory.NormalFactory;
import User.Factory.UserFactory;
import User.User;

import java.util.Scanner;

public class LibrarySystem {

    public static void main(String[] args) {
        UserFactory adminFactory = new AdminFactory();
        User admin1 = adminFactory.createUser("唐僧", 1);

        UserFactory normalFactory = new NormalFactory();
        User normal1 = normalFactory.createUser("悟空", 2);
        User normal2 = normalFactory.createUser("八戒", 3);
        ProxyUser proxyAdiminUser = new ProxyUser(admin1);
        ProxyUser proxyNormalUser1 = new ProxyUser(normal1);
        ProxyUser proxyNormalUser2 = new ProxyUser(normal2);
        LibrarySystem librarySystem = new LibrarySystem();
        ProxyUser currentproxyUser = LibrarySystem.selectProxyRole(proxyAdiminUser,
                                                                   proxyNormalUser1, proxyNormalUser2);

        while (true){
            int choice = currentproxyUser.display();
            currentproxyUser.handleoperation(choice);
        }
        }
    public static ProxyUser selectProxyRole(ProxyUser proxyAdiminUser,
                                            ProxyUser proxyNormalUser1, ProxyUser proxyNormalUser2) {
        System.out.println("请选择用户角色：1.管理员 2.普通用户 3.管理员用户 4.退出系统");
        ProxyUser currentUser = null;
        Scanner scanner = new Scanner(System.in);
        int role = scanner.nextInt();
        switch (role) {
            case 1:
                currentUser = proxyAdiminUser;
                break;
            case 2:
                currentUser = proxyNormalUser1;
                break;
            case 3:
                currentUser = proxyNormalUser2;
                break;
            case 4:
                System.out.println("退出系统");
                System.exit(0);
                break;
            default:
                break;
        }
        return currentUser;
    }
}
